package com.wechat.api.to;

import java.io.Serializable;
import java.util.HashMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 通用返还值
 * 
 * @author
 *
 */
public class ReturnObjectTO extends HashMap<String,Object> implements Serializable{


	/**
	 * 
	 */
	private static final long serialVersionUID = 8645900824350549932L;
	private static Logger logger = LogManager.getLogger(ReturnObjectTO.class);
    //失败原因
	//0:失败  1：成功  99：重复提交 其他数据可以自定义
	
	public String getMsg() {
		return this.get("msg")==null?null:this.get("msg").toString();
	}
	public void setMsg(String msg) {
		this.put("msg", msg);
	}
	public int getCode() {
		return Double.valueOf(this.get("code").toString()).intValue();
	}
	public void setCode(int code) {
		this.put("code", code);
	}

	public static ReturnObjectTO  success() {
		ReturnObjectTO res = new ReturnObjectTO();
		res.put("code", 1);
		res.put("msg", "成功");
		return res;
	}
	public static ReturnObjectTO  error(String errMsg) {
		ReturnObjectTO res = new ReturnObjectTO();
		res.put("code", 0);
		res.put("msg", errMsg);
		return res;
	}
	
	public static ReturnObjectTO  other(int code,String errMsg) {
		ReturnObjectTO res = new ReturnObjectTO();
		res.put("code", code);
		res.put("msg", errMsg);
		return res;
	}
}
